package com.face.server.repository;

import com.face.server.entity.Bulletin;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.Date;
import java.util.List;

public interface BulletinRepository extends MongoRepository<Bulletin, String> {

    List<Bulletin> findBySendToContains(int build);

    @Query("{$and:[" +
            "        {'effectDate': {$gte: ?0}},\n" +
            "        {'endDate' :{$lte: ?1}},\n" +
            "        {$or: [\n" +
            "                {adminName: {$regex: ?2}},\n" +
            "                {title: {$regex: ?2}}\n" +
            "            ]}\n" +
            "    ]}")
    List<Bulletin> findBy(Date bein, Date end, String input, Pageable pageable);

    void deleteByIdIn(List<String> ids);
}
